-- ====================================
-- Initialize the Class section of the 
-- Orunj table.
-- ====================================
Orunj.classes = { 
					["HUNTER"] = {}, -- dps			
					["WARLOCK"] = {}, -- dps
					["PRIEST"] = {}, -- healing/dps
					["PALADIN"] = {}, -- tank/heals/dps
					["MAGE"] = {}, -- dps
					["ROGUE"] = {}, -- dps
					["DRUID"] = {}, -- tank/heals/dps
					["SHAMAN"] = {}, -- heals/dps
					["WARRIOR"] = {}, -- tank/dps
					["DEATHKNIGHT"] = {}, -- tank/dps
				}
Orunj.roles = { 
					dps = "dps", -- deals damage 
					tank = "tank", -- absorbs damage
					heals = "heals" -- heals other players who have taken damage 
			  }

-- ====================================
-- For each class, make a function to
-- extract the role from talent points.
-- ====================================
-- Hunters can only DPS, and in some very special
-- occasions, are used for kiting - but that's not something
-- you can discern necessarily in their spec.
function Orunj.classes.HUNTER:GetRole(orunjPlayer)
	return Orunj.roles.dps
end

function Orunj.classes.HUNTER:GetTalentTrees()
	return {["Marksmanship"] = {points = 0},
			["Beast Mastery"] = {points = 0},
			["Survival"] = {points = 0},
			}
end

-- Warlocks are a strict DPS class
function Orunj.classes.WARLOCK:GetRole(orunjPlayer)
	return Orunj.roles.dps
end

function Orunj.classes.WARLOCK:GetTalentTrees()
	return {["Demonology"] = {points = 0},
			["Affliction"] = {points = 0},
			["Destruction"] = {points = 0},
			}
end

-- Priests have two healing trees, and one dps tree.
function Orunj.classes.PRIEST:GetRole(orunjPlayer)
	-- Get the trees
	local disc = orunjPlayer.talentTrees["Discipline"]
	local shadow = orunjPlayer.talentTrees["Shadow"]
	local holy = orunjPlayer.talentTrees["Holy"]
	-- Determine which tree has the most points.
	if (disc.points > shadow.points) or (holy.points > shadow.points) then
		return Orunj.roles.heals
	else
		return Orunj.roles.dps
	end 
end

function Orunj.classes.PRIEST:GetTalentTrees()
	return {["Discipline"] = {points = 0},
			["Shadow"] = {points = 0},
			["Holy"] = {points = 0},
			}
end

-- Paladins can be tanks, healers or DPSers
function Orunj.classes.PALADIN:GetRole(orunjPlayer)
	-- Get the trees.
	local prot = orunjPlayer.talentTrees["Protection"]
	local holy = orunjPlayer.talentTrees["Holy"]
	local ret = orunjPlayer.talentTrees["Retribution"]
	-- Determine which tree has the most points.
	if prot.points > holy.points and prot.points > ret.points then
		return Orunj.roles.tank
	elseif holy.points > prot.points and holy.points > ret.points then
		return Orunj.roles.heals
	else
		return Orunj.roles.dps
	end
end

function Orunj.classes.PALADIN:GetTalentTrees()
	return {["Protection"] = {points = 0},
			["Holy"] = {points = 0},
			["Retribution"] = {points = 0},
			}
end

-- Mages are a strict DPS class
function Orunj.classes.MAGE:GetRole(orunjPlayer)
	return Orunj.roles.dps
end

function Orunj.classes.MAGE:GetTalentTrees()
	return {["Fire"] = {points = 0},
			["Frost"] = {points = 0},
			["Arcane"] = {points = 0},
			}
end

-- Rogues are a strict DPS class
function Orunj.classes.ROGUE:GetRole(orunjPlayer)
	return Orunj.roles.dps
end

function Orunj.classes.ROGUE:GetTalentTrees()
	return {["Subtlety"] = {points = 0},
			["Combat"] = {points = 0},
			["Assassination"] = {points = 0},
			}
end
-- Druids can be tanks, healers or DPSers.
function Orunj.classes.DRUID:GetRole(orunjPlayer)
	-- Get the trees.
	local balance = orunjPlayer.talentTrees["Balance"]
	local resto = orunjPlayer.talentTrees["Restoration"]
	local feral = orunjPlayer.talentTrees["Feral Combat"]
	-- Determine the spec
	if balance.points > resto.points and balance.points > feral.points then
		return Orunj.roles.dps
	elseif resto.points > balance.points and resto.points > feral.points then
		return Orunj.roles.heals
	else
		if (feral["Protector of the Pack"] > 0) or
		   (feral["Survival of the Fittest"] > 0) or 
		   (feral["Natural Reaction"] > 0) or
		   (feral["Thick Hide"] > 0) then
		   	-- Bear tank.
			return Orunj.roles.tank
		else
			-- Cat DPS
			return Orunj.roles.dps
		end
	end
end

function Orunj.classes.DRUID:GetTalentTrees()
	return {["Balance"] = {points = 0},
			["Restoration"] = {points = 0},
			["Feral Combat"] = {points = 0},
			}
end

-- Shamans can be healers, or DPSers
function Orunj.classes.SHAMAN:GetRole(orunjPlayer)
	-- Get the trees.
	local enh = orunjPlayer.talentTrees["Enhancement"]
	local elem = orunjPlayer.talentTrees["Elemental"]
	local resto = orunjPlayer.talentTrees["Restoration"]
	-- Determine the spec
	if resto.points > enh.points and resto.points > elem.points then
		return Orunj.roles.heals
	else
		return Orunj.roles.dps
	end 
end

function Orunj.classes.SHAMAN:GetTalentTrees()
	return {["Enhancement"] = {points = 0},
			["Elemental"] = {points = 0},
			["Restoration"] = {points = 0},
			}
end

-- Warriors can be tanks, or DPSers
function Orunj.classes.WARRIOR:GetRole(orunjPlayer)
	-- Get the trees,
	local fury = orunjPlayer.talentTrees["Fury"]
	local prot = orunjPlayer.talentTrees["Protection"]
	local arms = orunjPlayer.talentTrees["Arms"]
	-- Determine the spec
	if prot.points > fury.points and prot.points > arms.points then
		return Orunj.roles.tank
	else
		return Orunj.roles.dps
	end
end

function Orunj.classes.WARRIOR:GetTalentTrees()
	return {["Fury"] = {points = 0},
			["Protection"] = {points = 0},
			["Arms"] = {points = 0},
			}
end

-- Deathknights can be tanks, or DPSers
function Orunj.classes.DEATHKNIGHT:GetRole(orunjPlayer)
	-- Get the trees.
	local unholy = orunjPlayer.talentTrees["Unholy"]
	local frost = orunjPlayer.talentTrees["Frost"]
	local blood = orunjPlayer.talentTrees["Blood"]
	-- Determine the spec.
	if unholy["Anticipation"] > 0 and frost["Toughness"] > 0 and blood["Blade Barrier"] > 0 then
		return Orunj.roles.tank
	else
		return Orunj.roles.dps	
	end
end

function Orunj.classes.DEATHKNIGHT:GetTalentTrees()
	return {["Unholy"] = {points = 0},
			["Frost"] = {points = 0},
			["Blood"] = {points = 0},
			}
end